home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / Documentation / ODF Dev Guide (Acrobat) / ODF Developer's Guide Update < prev    next >
Encoding:
Text File  |  1996-08-16  |  14.6 KB  |  241 lines  |  [ttro/ttxt]

  1. OpenDoc
  2. Development
  3. Framework
  4.                                                                                                                                                                                          
  5. ODF Developer's Guide Update 
  6. ODF Release 1                                                                                                                                                                  
  7.  
  8.  
  9. Table of Content
  10. ------------------
  11. • Abstract
  12. • Chapter 3.  Handling Events
  13. • Chapter 4.  Managing Your Part's Interface
  14. • Chapter 7.  Data Interchange
  15. • Chapter 9.  Programming Services
  16.  
  17.  
  18.  
  19. Abstract
  20.  
  21. The Developer's Guide PDF file shipped with ODF release 1 contains several inaccuracies which could not be updated in time.  Please check the ODF web page at /www.devtools.apple.com/odf/ where we will post an updated version of the Developer's Guide as soon as possible or use this document (and the various Engineering Notes) to make sure that you have the latest information.
  22.  
  23. In general the sample code listings taken directly from an ODF class (i.e. starting with FW_) or an ODF example may be a little bit out of date, so we recommend that you open the corresponding source file or use a class browser to check the correct implementation.
  24.  
  25.  
  26. Chapter 3.  Handling Events
  27.  
  28. Page 64-65.  Handling Virtual key Events
  29.  
  30. The code listing 3-2 is out of date:
  31.  
  32. • You don't need to shift the keyCode returned by GetKeyCode:
  33.  
  34. short keyCode = theVirtualKeyEvent.GetKeyCode(ev); 
  35. // short shiftedCode = keyCode >> 8;   this bug was fixed in ODF 1
  36.  
  37. • The keyCode constants have been modified to follow ODF naming conventions (see FWEveDef.h)
  38.  
  39. FW_BACKSPACE -> FW_kVKBackspace
  40. FW_RIGHT     -> FW_kVKRight
  41. FW_ENTER     -> FW_kVKEnter
  42.  
  43. Page 70.  Handling Activation Events
  44.  
  45. This section omits to explain the 2 kinds of activation occuring in parts:  
  46. 1) The window activation, which is the traditional activate/deactivate events sent by the Mac OS when a window comes to the front or is pushed behind. 
  47. 2) the part activation in the OpenDoc sense when a part's frame acquires the selection focus.   
  48.  
  49. For a general discussion on OpenDoc activation, please see the OpenDoc Programmers Guide : Mouse Events, Activation and Dradding page 198, and UI Guidelines on Activation page 559.
  50.  
  51. ODF dispatches the DoActivateEvent method in response to window activation. You can use this method  in your views (including your frames) to change the highlighting of a particular object.  For instance ODF activates/deactivates scrollbars when the window becomes active/inactive to follow the Macintosh HI guidelines.
  52.  
  53. The code listing 3-8 is out of date:  DoActivateEvent returns void instead of FW_Boolean, activate events are always propagated to all the views.
  54.  
  55. Page 71.  Responding to Activations
  56.  
  57. As noted above this section should distinguish between window and part activation.  The methods IsActive, Activate and Deactivate don't exist anymore. 
  58.  
  59. In response to window activation ODF transfer the selection focus to the frame which last had it before the window was deactivated  (Note: if the window is activated in response to a mouse-down event, the selection focus was already transferred to the frame where the event occured).
  60.  
  61. When your part receives an activation its main responsibility is to highlight the current selection, if it has the selection focus.   For example the Container sample draws selection handles around its embedded parts.  It implements DoActivateEvent to respond to the window activation and overrides FocusStateChanged to respond to part activation:
  62.  
  63. // Response to window activation
  64. void CContainerFrame::DoActivateEvent(Environment* ev, 
  65.                                       const FW_CActivateEvent& theActivateEvent)
  66. {
  67.       if (HasSelectionFocus(ev))
  68.              fSelection->RenderAllHandles(ev, this);
  69. }
  70.  
  71. // Response to part activation
  72. void CContainerFrame::FocusStateChanged(Environment* ev, ODTypeToken focus, 
  73.                                        FW_Boolean newState, ODFrame* newOwner)
  74. {
  75.     FW_CEmbeddingFrame::FocusStateChanged(ev, focus, newState, newOwner);
  76.     
  77.      if (focus == FW_CPart::gSelectionFocusToken)
  78.      {
  79.         //    • If I get the selection focus I redraw the handles only if the window is not active
  80.         //    if the window is active they already have been redrawn by DoActivateEvent
  81.         //    • If I am loosing the selection focus I redraw the handles only if the window is active
  82.         //    if the window is not active they already have been redrawn by DoActivateEvent
  83.         //    The events order is:
  84.         //        - Window 1 deactivated
  85.         //        - Frame 1 lose selection focus
  86.         //        - Frame 2 gain selection focus
  87.         //        - Window 2 activated
  88.            FW_Boolean windowActive = GetWindow(ev)->IsActive(ev);
  89.            FW_Boolean hilite = newState ? !windowActive : windowActive;
  90.            if (hilite)
  91.                   fSelection->RenderAllHandles(ev, this);
  92.      }
  93. }
  94.  
  95. Note:  See also the update below regarding part activation when the user click in a view outside the active frame.
  96.  
  97.  
  98. Chapter 4.  Managing Your Part's Interface
  99.  
  100. Page 84-85.  Working With Views
  101.  
  102. The term container view should be replaced by parent view to avoid any confusion with container parts.  A parent view is an instance of the class FW_CSuperView, its main difference with a normal view is that it can contain other subviews and can scroll.  It is not a container in the OpenDoc sense, i.e. doesn't allow embedding of other parts (the property of embedding must be implemented at the frame level with the class FW_CEmbeddingFrame).
  103.  
  104. Page 85.  Add section explaining the concept of content view 
  105.  
  106. A frame contains a special view called the content view  used to display the part’s content and to embed other parts. There can only be 1 content view per frame because its coordinate space is defined by the frame’s internal transform maintained by OpenDoc.  In figure 4-3, page 86, the content view is the gray area containing the visible portion of the bitmap.  Because the content view displays the part's content it is the only view  which can scroll within the frame, see "Scrolling Your View" below.
  107.  
  108. By default a FW_CFrame object is created as being its own content view.  You don't need to change anything if your part's content doesn't require scrolling within that frame.  However, if you want to define a scrolling area to display your content it is necessary to create  a subview as the content view and create two scrollbar views.
  109.  
  110. Content views can be created by code or by resources.  You must first define your own subclass of FW_CSuperView.  If you are implementing your frame's CreateSubViews method this is where you  create an instance of your subclass and call the MakeContentView method.  If you are using view resources you must define a resource type for your subclass and list a view of that type in your FW_RFrameLayout resource, with the value 1 for its contentView flag.  See the  Container or Form samples.
  111. Be sure to set the scrollingDirection field to FW_kXYScrolling.
  112.  
  113. You don’t need to keep the content view as a class field because that’s already done in FW_CFrame. You can retrieve it later with GetContentView():
  114.         contentView = myCFrame->GetContentView(ev);
  115.  
  116. Use IsContentView(ev) and IsInContentView(ev) to test if a view is the content view or is inside the content view.
  117.  
  118. Page 85.  Add note on part activation when clicking in views
  119.  
  120. If the user clicks in a view belonging to a non active frame (i.e. non active part) several things can occur:
  121.  
  122. • If the frame belongs to a non-active window the window is first activated.
  123. • If the frame is not the root frame, i.e.  is embedded inside another frame, then it is first activated.
  124. • If the frame is the root frame, then it is activated only if the view wants to become the target.  In ODF 1 only edit-views and list-boxes can become the target (i.e. process key events), clicking in such views must activate their frame in order for them to receive key events.  On the other hand clicking on controls belonging to the root frame won't activate it.
  125.  
  126. A future release of ODF will provide more flexibility for managing part and frame activation when handling mouse events in views.  The acceptable behavior can depend on your part's content, there is no strict HI guideline at this level of granularity.
  127.  
  128. Page 85-86.  View Coordinate Spaces
  129.  
  130. It should be noted that view coordinate space and view-content coordinate space are different only for superviews whose extent is bigger than their bounds size (i.e. supports scrolling).  In cases of simple views, or superviews with an extent equal to their bound size, there is only 1 coordinate space.
  131.  
  132. Note: if a view extent is smaller than its bounds size you can still draw outside the extent within the bounds rectangle.  For instance the content view of a drawing program could have a small drawing area and a gray region outside.
  133.  
  134. See ODF Draw  for an example using rulers.
  135.  
  136. Page 87-88.  Defining a Subview
  137.  
  138. The view hierarchy inside your frame will never be very deep.  Usually a frame contains simple views, such as controls, as direct children, and it may contain a content view  which itself contains other simple views.  It is rare that you use more than 2 layers of views because of the limitation
  139.  
  140. Note: in order to group several views together visually, such as several radio buttons, consider using a FW_CGroupBox object, it's simpler than creating a parent view just for this visual effect.  However creating your own FW_CSuperView class for that purpose allows you to customize its drawing and manage the layout management of its subviews.
  141.  
  142. Page 88-93.  Creating Subviews (and ajusting the view layout)
  143.  
  144. This section doesn't talk about creating views from resources instead of implementing CreateSubViews.  It is a simpler and more maintainable way of dealing with your part's interface.   See the Engineering note "Defining Views in resources" and the Form or Container samples (When you pass a resource id to your frame's constructor its method CreateSubViews won't be called.)
  145.  
  146. Listing 4-5 for CFormFrame::CreateSubViews  is an old version.  You should go directly to the current code in ODF:Form:Sources:Frame.cpp and ODF:Form:Sources:FormView.cpp
  147.  
  148. The method AdjustSubViews  doesn't exist anymore and listing 4-6 is obsolete.  The Form sample uses the ODF built-in layout management for most of its views and implements CFormView::AdjustToNewLayout for centering the content view.   See the Engineering  note "Layout Management" for more information.
  149.  
  150. Page 93-95. Adding Controls to Your View
  151.  
  152. This section is superseded by the Engineering note "Using Controls".
  153.  
  154. Controls are easier to define in resources like all views.   The method AdjustSubViews doesn't exist anymore.  The layout  of controls is managed  by the view binding flag as described in the Engineering note "Layout Management".  By default buttons and popup menus keep fixed bounds and scrollbars follow the right and bottom edge of their parent view.
  155.  
  156. The method SetDefault doesn't exist anymore and the class FW_CPushButton has been merged in FW_CButton.  The sample code to create a push button on page 94 should be replaced by:
  157.  
  158.  FW_CString label("Join ODFWired");
  159.     FW_CButton* button = FW_NEW(FW_CButton, (ev, this, 0, buttonRect, FW_kPushButton, 
  160.                                                            label, FW_kNormalFont, FW_kDefaultButtonMsg));
  161.  
  162. Note that you must use the macro FW_NEW instead of new because all views are auto-destruct objects. The button kind is FW_kPushButton and the control's message is FW_kDefaultButtonMsg.  Using this message is enough to indicate that you want it to be drawn as a default button.
  163.  
  164.  
  165. Chapter 7.  Data Interchange
  166.  
  167. Pages 250-251.  Making Your Selection Publishable
  168.  
  169. The code listings are out of date:
  170.  
  171. Listing 7-45 Verifying whether a selection can be published
  172.  
  173. FW_Boolean CDrawSelection::IsSelectionLinkable(Environment* ev)
  174. {
  175.     FW_Boolean result = TRUE;
  176.     
  177.     CDrawContentShapeIterator ite(fSelectionContent);
  178.     for (CBaseShape *shape = ite.First(); ite.IsNotComplete(); 
  179.     shape = ite.Next())
  180.     {
  181.         if (shape->IsInLinkDestination(ev))
  182.         {
  183.             result = FALSE;
  184.             break;
  185.         }
  186.         else if (shape->IsPublished())    // don't allow a shape to be
  187.                                           // ]published more than once
  188.         {
  189.             result = FALSE;
  190.             break;
  191.         }
  192.     }
  193.     
  194.     return result;
  195. }
  196.  
  197. FW_CSelection also defines the method CanPasteAsLink. This method is similar in function to the IsSelectionLinkable method, except that you can use this method to specify the preferred method of linking this data, whether that be by merging or embedding the data. Potential merge options include the following:
  198. • kODPasteAsEmbed
  199. • kODPasteAsEmbedOnly
  200. • kODPasteAsMerge
  201. • kODPasteAsMergeOnly
  202. Listing 7-46 shows the CanPasteAsLink method of CDrawSelection. This method returns the constant kODPasteAsMerge so that ODF will attempt to merge the selected data by default.
  203.  
  204. Listing 7-46 Verifying that your part can subscribe to data
  205.  
  206. FW_Boolean CDrawSelection::CanPasteAsLink(Environment* ev, 
  207.                                           ODPasteAsMergeSetting& setting,
  208.                                           ODStorageUnit* su)
  209. {
  210.     // Check whether the storage unit contains mergeable content
  211.     if (su->Exists(ev, kODPropContents, fDrawPart->GetPartKind(ev), 0))
  212.         setting = kODPasteAsMerge;
  213.     else    // foreign content - cannot be merged
  214.         setting = kODPasteAsEmbedOnly;
  215.     
  216.     return fAllowLink;
  217. }
  218.  
  219. Page 252.  Add section on Link Borders and Selection
  220.  
  221. The two classes representing links, FW_CLinkSource and FW_CLinkDestination, are now derived from a common base class. FW_CLink provides an API for implementing link borders and link selection, although support for these features in ODF is incomplete. 
  222.  
  223. To implement link borders, override DoCreateLinkBorderShape and DoDrawLinkBorder. In  DoCreateLinkBorderShape create and return a shape representing the border around the linked data. In DoDrawLinkBorder use this shape to draw the actual border.
  224.  
  225.     virtual ODShape* DoCreateLinkBorderShape(Environment* ev);
  226.     virtual void DoDrawLinkBorder(Environment* ev, ODShape* outline, FW_CGraphicContext& gc);
  227.  
  228. See the classes CTableLink and CTableLinkSources in the Table sample for examples of overriding DoCreateLinkBorder and DoDrawLinkBorder.
  229.  
  230. To determine whether the user clicked on a link border, call IsMouseInBorder from your DoMouseDown method. Call IsLinkSelected to determine whether the link was already selected, and then call Select to change the link’s selection state.
  231.  
  232.  
  233. Chapter 9.  Programming Services
  234.  
  235. Page 312-314.  Using the Notifications Subsystem
  236.  
  237. This section is superseded by the Engineering  note "Notification" in the folder Engineering Notes:Foundation:
  238.  
  239.  
  240. © 1993 - 1996 Apple Computer, Inc. All rights reserved.
  241. Apple, the Apple Logo, Macintosh, and OpenDoc are trademarks of Apple Computer, Inc., registered in the United States and other countries.